from timeseries import get_time_series
from models import ChartView
from gviz_api import DataTable
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
import os

class QueryHandler (webapp.RequestHandler):
	def get(self):
		table_description = [ ('Date','date'),
					('Unemployment rate - Australia','number'),('title1','string'),
					('Unemployment rate - US', 'number'), ('title2','string') ]
		filenames = ["unemployment_rate_australia.ts","unemployment_rate_us.ts"]
		table_data = format_time_series (filenames, (1,2,1978),(1,2,2010), value_padding=1)

		table_data[266][4] = "Burst of dot-com bubble"

		data_table = DataTable (table_description)
		data_table.LoadData (table_data)

		json = data_table.ToJSonResponse (columns_order=("Date","Unemployment rate - Australia", "title1", "Unemployment rate - US", "title2"))
		self.response.headers['Content-Type'] = 'application/json'
		self.response.out.write (json)
